package com.way.demo.test;

import java.util.Scanner;

/**
 * @author lipingwei
 * @create 2022-04-08 18:13
 */
public class MainTest1 {
    public static void main(String[] args) {

//        int days = dayOfYear(2016, 2, 1);
//        System.out.println("当前年的第 " + days+ "天");

        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();

        char[] chars = str.toCharArray();
        String n = String.valueOf(chars[0]);
        String a1 = String.valueOf(chars[1]);
        String a2 = String.valueOf(chars[2]);
        String a3 = String.valueOf(chars[3]);
        String a4 = String.valueOf(chars[4]);

        System.out.println("输入长度为："  + n + "字符数组");
        String str2 = scanner.nextLine();
        scanner.close();
       String str3= str2.replace(a1,a2);
       String str4= str3.replace(a3,a4);
        System.out.println(str4);





    }

    /**
     * 输入 yyyy-MM-dd 返回当前日期为当前年的第多少天
     * @param year
     * @param month
     * @param day
     * @return
     */
    public static int dayOfYear(int year ,int month , int day){
        int days=0;
        for (int m = 1; m < month; m++) {
            days += getMonthdays(year, m);
        }
        //month当月的天数累加
        days += day;
        return days;

    }


    private static int getMonthdays(int year, int month) {

        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                return 31;
            case 4:
            case 6:
            case 9:
            case 11:
                return 30;
            case 2:
                //闰年二月29天
                //平年二月28天
                if (leapYear(year)) {
                    return 29;
                }
                else {
                    return 28;
                }
            default:
                break;
        }
        return 0;
    }


    //闰年判断方法
    private static boolean leapYear(int year) {

        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            return true;
        }
        return false;
    }

}
